home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / BODI / ASM.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  3.3 KB  |  195 lines

  1. /******************************************************************/
  2. /* HISTORY                              */
  3. /*                                  */
  4. /* 11/07/89 - f_move(),Lf_move(),r_move() and Lr_move() have been */
  5. /*          moved to fast.s and rewritten in assembly.          */
  6. /******************************************************************/
  7. #include    "defs.h"
  8.  
  9. /*
  10.     This module is a good candidate to be rewritten
  11.     in assembly language.
  12. */
  13.  
  14. /*
  15.     Function to forward move a block.
  16. */
  17.  
  18. /*
  19. Lf_move(source, target, count)
  20. unsigned char    *source, *target;
  21. unsigned long    count;
  22. {
  23.     while (count--) *target++ = *source++;
  24. }
  25. */
  26.  
  27. /*
  28.     Function to reverse move a block.
  29. */
  30. /*
  31. Lr_move(source, target, count)
  32. unsigned char    *source, *target;
  33. unsigned long    count;
  34. {
  35.     while (count--) *target-- = *source--;
  36. }
  37. */
  38.  
  39. /*
  40.     Function to copy a block.
  41. */
  42. memcpy(target, source, count)
  43. unsigned char    *target, *source;
  44. unsigned    count;
  45. {
  46.     f_move(source, target, count);
  47. }
  48.  
  49. /*
  50.     Function to fill a block with a byte value.
  51. */
  52. memset(target, value, count)
  53. unsigned char    *target, value;
  54. unsigned    count;
  55. {
  56.     while (count--) *target++ = value;
  57. }
  58.  
  59. /*
  60.     Function to compare two blocks.
  61. */
  62. memcmp(target, source, count)
  63. unsigned char    *target, *source;
  64. unsigned    count;
  65. {
  66.     while (count--) if (*target++ != *source++)
  67.         return(1);
  68.     return(0);
  69. }
  70.  
  71. /*
  72.     Routine to truncate source string "s" at '.' by looking backward.
  73.     Process is stopped if a '\' is found.
  74. */
  75. strunc(s)
  76. unsigned char    s[];
  77. {
  78.     unsigned    i;
  79.     unsigned char    c;
  80.  
  81.     i = strlen(s);
  82.     while (i && (c = s[i-1]) != '\\' && c != '.')
  83.         --i;
  84.     if (c == '.') s[i-1] = 0;
  85. }
  86.  
  87. /*
  88.     Function to change a lower case alpha character to upper case.
  89.     Returns new or old character.
  90. */
  91. char    toupper(c)
  92. char    c;
  93. {
  94.     if (c >= 'a' && c <= 'z') c -= 0x20;
  95.     return(c);
  96. }
  97.  
  98. /*
  99.     Routine to check if character "c" is an alphabet.
  100.     True returns 1 else 0.
  101. */
  102. calpha(c)
  103. char    c;
  104. {
  105.     return((c >= 'A' && c <= 'Z')||(c >= 'a' && c <= 'z'));
  106. }
  107.  
  108. /*
  109.     Routine to check if character "c" is a digit.
  110.     True returns 1 else 0.
  111. */
  112. cdigit(c)
  113. char    c;
  114. {
  115.     return(c >= '0' && c <= '9');
  116. }
  117.  
  118. /*
  119.     Routine to check if character "c" is a Start or End CP TAG.
  120.     True returns 1 else 0.
  121. */
  122. ctagc(c)
  123. char    c;
  124. {
  125.     return(c == STAG || c == ETAG);
  126. }
  127.  
  128. /*
  129.     Routine to check if character "c" is a PI TAG.
  130.     True returns 1 else 0.
  131. */
  132. ptagc(c)
  133. char    c;
  134. {
  135.     return(c == PTAG);
  136. }
  137.  
  138. /*
  139.     Routine to check if character "c" is a PI or CP TAG.
  140.     True returns 1 else 0.
  141. */
  142. tagc(c)
  143. char    c;
  144. {
  145.     return(ptagc(c) || ctagc(c));
  146. }
  147.  
  148. /*
  149.     Function to check if char c is a non compose one.
  150.     True returns 1 else 0.
  151. */
  152. nocp(c)
  153. char    c;
  154. {
  155.     return( c == DH || c == cr || c == lf || c == Rf ||
  156.         c == QL || c == QR || c == QC );
  157. }
  158.  
  159. /*
  160.     Function to check if char c is any line ending one.
  161.     True returns 1 else 0.
  162. */
  163. allend(c)
  164. char    c;
  165. {
  166.     return(c == srt || c == hrt || c == Rf);
  167. }
  168.  
  169. /*
  170.     Function to check if char at "ptr" is any cursor line ending one.
  171.     True returns 1 else 0.
  172. */
  173. lpend(ptr)
  174. char    *ptr;
  175. {
  176.     return(*ptr == cr || allend(*ptr));
  177. }
  178.  
  179. /*
  180.     Function to setup Long char format.
  181. */
  182. start(arr,i,c)
  183. unsigned char    *arr;
  184. unsigned    i;
  185. unsigned char    c;
  186. {
  187.     union {
  188.         unsigned char    byt[2];
  189.         unsigned    val;
  190.     } w;
  191.     w.val    = i | (c << 8);
  192.     *(++arr)= w.byt[0];
  193.     *(++arr)= w.byt[1];
  194. }
  195.